/**
 * Created by shudong.msd(风骐) on 2016/4/17.
 */

app.controller('indexVarietySearchCtrl', ['$scope', '$http','$state','datepickerService','keywordsService','searchService',function($scope, $http,$state,datepickerService,keywordsService,searchService) {
    $scope.placeholdertext = "输入需要查询的综艺节目";

    $scope.$watch('search_tags.length', function(value) {
        if(value==undefined){
            $scope.currentTags = 0;
            return;
        }
        $scope.currentTags = value;
        var $taginput = $("#variety_pane tags-input input");
        if(value==5){
            $taginput.attr('placeholder',"");
            $taginput.attr('disabled','true');
        }else{
            if($taginput.attr('disabled')){
                $taginput.attr('placeholder', $scope.placeholdertext );
                $taginput.attr('disabled',null);
            }
        }
    });

    $scope.search_tags = [];
    $scope.loadTags = function($query) {

        return  keywordsService.loadWords('variety',$query);
    };



    $scope.formData={'startTime':'','endTime':''};
    $scope.processForm = function(invalid) {
        if(!invalid){
            alert('请输入全部要查询信息');
            return;
        }
        searchService.proFormDetail($scope,3);

        sessionStorage.setItem('searchData',JSON.stringify($scope.formData));

        $state.go('main.sResult.detail',{type:'variety'});

    };

    datepickerService.callDatePicker($("#variety_pane .mz-datepicker input"));


}]);
